home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / FLI106C.ZIP;1 / WINCHECK.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-12  |  7.5 KB  |  289 lines

  1. //
  2. // The Fusion Library Interface for DOS
  3. // Version 1.06c
  4. // Copyright (C) 1990, 1991, 1992
  5. // Software Dimensions
  6. //
  7. // FusionWindow
  8. //
  9.  
  10. #include "fliwin.h"
  11. #include "colors.h"
  12.  
  13. #ifdef __BCPLUSPLUS__
  14. #pragma hdrstop
  15. #endif
  16.  
  17. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  18. //
  19. // CheckMoveOrSize()
  20. //
  21. // Checks the current window and moves or sizes it
  22. //
  23. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  24.  
  25. int FusionWindow::CheckMoveOrSize()
  26. {
  27.   if (!NumberOfWindows)
  28.     return 0;
  29.  
  30.   WindowElement &Window=*Windows[0];
  31.  
  32.   //--------------------------------------------------------------------------
  33.   //
  34.   // Size the window
  35.   //
  36.   //--------------------------------------------------------------------------
  37.  
  38.   if (Window.SizeIcon
  39.     && MouseVertical==Window.Y+Window.Height-1
  40.     && MouseHorizontal==Window.X+Window.Width-1)
  41.   {
  42.     RemoveAllMenus();
  43.  
  44.     BlazeClass::InvisibleCursor();
  45.  
  46.     if (NumberOfWindows && Windows[0]->CurrentLevel)
  47.       Windows[0]->RemoveAllMenus();
  48.  
  49.     int ActionX=MouseHorizontal;
  50.     int ActionY=MouseVertical;
  51.  
  52.     char *EntireWindow=
  53.       new char[Blaze.ComputeNeededBytes(Blaze.WhatWidth(),Blaze.WhatHeight())];
  54.     char *ThisWindow=
  55.       new char[Blaze.ComputeNeededBytes(Window.Width,Window.Height)];
  56.  
  57.     Blaze.UseMemory(EntireWindow);
  58.     Blaze.CharacterFill(0,1,Blaze.WhatWidth(),Blaze.WhatHeight()-2,
  59.       Colors.WorkSpace,176);
  60.  
  61.     Windows[0]->WindowZoomed=0;
  62.  
  63.     if (NumberOfWindows>1)
  64.     {
  65.       for (register int i=NumberOfWindows-1;i;i--)
  66.       {
  67.         Windows[i]->Blaze.UseMemory(EntireWindow);
  68.         Windows[i]->ShowWindow();
  69.         Windows[i]->ShowInterior();
  70.         Windows[i]->Blaze.UseVideo();
  71.       }
  72.     }
  73.  
  74.     Blaze.GetArea(Window.X,Window.Y,Window.Width,Window.Height,ThisWindow);
  75.  
  76.     Blaze.HelpLine(0,"Use the mouse to expand or contract the size of the window");
  77.  
  78.     Window.Blaze.UseMemory(EntireWindow);
  79.     Window.ShowWindow();
  80.     Window.ShowInterior();
  81.     Window.Blaze.UseVideo();
  82.  
  83.     MouseHide();
  84.  
  85.     Blaze.BlockCopyVirtualToVisual(0,1,Blaze.WhatWidth(),Blaze.WhatHeight()-2,
  86.       EntireWindow);
  87.  
  88.     MouseShow();
  89.  
  90.     for (;;)
  91.     {
  92.       GetEvent();
  93.  
  94.       if (MouseEvent&4)
  95.       {
  96.         LastShift=500;
  97.         KeyLast=500;
  98.         delete ThisWindow;
  99.         delete EntireWindow;
  100.         Blaze.UseVideo();
  101.         Window.Cursor();
  102.         Window.EventHandler(SizeEvent);
  103.         return 1;
  104.       }
  105.  
  106.       if (MouseEvent&1)
  107.       {
  108.         MouseHide();
  109.  
  110.         Blaze.PutArea(Window.X,Window.Y,ThisWindow);
  111.         delete ThisWindow;
  112.  
  113.         Window.Width+=(MouseHorizontal-ActionX);
  114.         Window.Height+=(MouseVertical-ActionY);
  115.  
  116.         ActionX=MouseHorizontal;
  117.         ActionY=MouseVertical;
  118.  
  119.         if (Window.Width<Window.MinimumWidth || Window.Width<13)
  120.           Window.Width=Window.MinimumWidth;
  121.  
  122.         if (Window.Height<Window.MinimumHeight || Window.Height<5)
  123.           Window.Height=Window.MinimumHeight;
  124.  
  125.         if (Window.X+Window.Width>Blaze.WhatWidth())
  126.           Window.Width=Blaze.WhatWidth()-Window.X;
  127.  
  128.         if (Window.Y+Window.Height>Blaze.WhatHeight()-1)
  129.           Window.Height=Blaze.WhatHeight()-Window.Y-1;
  130.  
  131.         ThisWindow=
  132.           new char[Blaze.ComputeNeededBytes(Window.Width,Window.Height)];
  133.         Blaze.GetArea(Window.X,Window.Y,Window.Width,Window.Height,ThisWindow);
  134.         Window.Blaze.UseMemory(EntireWindow);
  135.         Window.ShowWindow();
  136.         Window.ShowInterior();
  137.         Window.Blaze.UseVideo();
  138.  
  139.         MouseHide();
  140.  
  141.         Blaze.BlockCopyVirtualToVisual(0,1,Blaze.WhatWidth(),Blaze.WhatHeight()-2,
  142.           EntireWindow);
  143.  
  144.         MouseShow();
  145.  
  146.         if (MouseVertical!=Window.Y+Window.Height-1 ||
  147.           MouseHorizontal!=Window.X+Window.Width-1)
  148.         {
  149.           MousePosition(Window.X+Window.Width-1,Window.Y+Window.Height-1);
  150.           MouseLocate();
  151.           ActionX=MouseHorizontal;
  152.           ActionY=MouseVertical;
  153.         }
  154.       }
  155.     }
  156.   }
  157.  
  158.   //--------------------------------------------------------------------------
  159.   //
  160.   // Move the window
  161.   //
  162.   //--------------------------------------------------------------------------
  163.  
  164.   if (Window.Moveable
  165.     && MouseVertical==Window.Y
  166.     && MouseHorizontal>=(Window.X+(Window.CloseIcon*3)+1)
  167.     && MouseHorizontal<=(Window.X+Window.Width-(Window.ZoomIcon*3)-3))
  168.   {
  169.     int ExactX=MouseHorizontal-Window.X;
  170.     int ExactY=MouseVertical-Window.Y;
  171.  
  172.     RemoveAllMenus();
  173.  
  174.     BlazeClass::InvisibleCursor();
  175.  
  176.     if (NumberOfWindows && Windows[0]->CurrentLevel)
  177.       Windows[0]->RemoveAllMenus();
  178.  
  179.     int ActionX=MouseHorizontal;
  180.     int ActionY=MouseVertical;
  181.  
  182.     char *EntireWindow=
  183.       new char[Blaze.ComputeNeededBytes(Blaze.WhatWidth(),Blaze.WhatHeight())];
  184.     char *ThisWindow=
  185.       new char[Blaze.ComputeNeededBytes(Window.Width,Window.Height)];
  186.     char *SpareWindow=
  187.       new char[Blaze.ComputeNeededBytes(Window.Width,Window.Height)];
  188.  
  189.     Blaze.UseMemory(EntireWindow);
  190.     Blaze.CharacterFill(0,1,Blaze.WhatWidth(),Blaze.WhatHeight()-2,
  191.       Colors.WorkSpace,176);
  192.  
  193.     if (NumberOfWindows>1)
  194.     {
  195.       for (register int i=NumberOfWindows-1;i;i--)
  196.       {
  197.         Windows[i]->Blaze.UseMemory(EntireWindow);
  198.         Windows[i]->ShowWindow();
  199.         Windows[i]->ShowInterior();
  200.         Windows[i]->Blaze.UseVideo();
  201.       }
  202.     }
  203.  
  204.     Blaze.HelpLine(0,"Use the mouse to move the window");
  205.  
  206.     Blaze.GetArea(Window.X,Window.Y,Window.Width,Window.Height,ThisWindow);
  207.  
  208.     Window.Blaze.UseMemory(EntireWindow);
  209.     Window.ShowWindow();
  210.     Window.ShowInterior();
  211.     Window.Blaze.UseVideo();
  212.  
  213.     MouseHide();
  214.  
  215.     Blaze.BlockCopyVirtualToVisual(0,1,Blaze.WhatWidth(),Blaze.WhatHeight()-2,
  216.       EntireWindow);
  217.     Blaze.GetArea(Window.X,Window.Y,Window.Width,Window.Height,SpareWindow);
  218.  
  219.     MouseShow();
  220.  
  221.     for (;;)
  222.     {
  223.       GetEvent();
  224.  
  225.       if (MouseEvent&4)
  226.       {
  227.         LastShift=500;
  228.         KeyLast=500;
  229.         delete SpareWindow;
  230.         delete ThisWindow;
  231.         delete EntireWindow;
  232.         Blaze.UseVideo();
  233.         Window.ReAlign();
  234.         Window.Cursor();
  235.         Window.EventHandler(MoveEvent);
  236.         return 1;
  237.       }
  238.  
  239.       if (MouseEvent&1)
  240.       {
  241.         MouseHide();
  242.  
  243.         Blaze.PutArea(Window.X,Window.Y,ThisWindow);
  244.         delete ThisWindow;
  245.  
  246.         Window.X+=(MouseHorizontal-ActionX);
  247.         Window.Y+=(MouseVertical-ActionY);
  248.  
  249.         ActionX=MouseHorizontal;
  250.         ActionY=MouseVertical;
  251.  
  252.         if (Window.X<0)
  253.           Window.X=0;
  254.  
  255.         if (Window.Y<1)
  256.           Window.Y=1;
  257.  
  258.         if (Window.X+Window.Width>Blaze.WhatWidth())
  259.           Window.X=Blaze.WhatWidth()-Window.Width;
  260.  
  261.         if (Window.Y+Window.Height>Blaze.WhatHeight()-1)
  262.           Window.Y=Blaze.WhatHeight()-Window.Height-1;
  263.  
  264.         MouseHide();
  265.  
  266.         ThisWindow=
  267.           new char[Blaze.ComputeNeededBytes(Window.Width,Window.Height)];
  268.         Blaze.GetArea(Window.X,Window.Y,Window.Width,Window.Height,ThisWindow);
  269.         Blaze.PutArea(Window.X,Window.Y,SpareWindow);
  270.         Blaze.BlockCopyVirtualToVisual(0,1,Blaze.WhatWidth(),Blaze.WhatHeight()-2,
  271.           EntireWindow);
  272.  
  273.         MouseShow();
  274.  
  275.         if (MouseVertical!=Window.Y+ExactY ||
  276.           MouseHorizontal!=Window.X+ExactX)
  277.         {
  278.           MousePosition(Window.X+ExactX,Window.Y+ExactY);
  279.           MouseLocate();
  280.           ActionX=MouseHorizontal;
  281.           ActionY=MouseVertical;
  282.         }
  283.       }
  284.     }
  285.   }
  286.   return 0;
  287. }
  288.  
  289.